{include file="common/mainHead"/}
<div class="admin-main fadeInUp animated" ng-app="hd" ng-controller="ctrl">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>{:lang('systemSet')}</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('websiteName')}</label>
            <div class="layui-input-4">
                <input type="text" ng-model="field.name" lay-verify="required" placeholder="{:lang('pleaseEnter')}{:lang('websiteName')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('WebsiteUrl')}</label>
            <div class="layui-input-4">
                <input type="text" ng-model="field.url" lay-verify="url" placeholder="{:lang('pleaseEnter')}{:lang('WebsiteUrl')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('seoTitle')}</label>
            <div class="layui-input-4">
                <input type="text" ng-model="field.title" lay-verify="required" placeholder="{:lang('pleaseEnter')}{:lang('WebsiteUrl')}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">{:lang('seoKeyword')}</label>
            <div class="layui-input-block">
                <textarea ng-model="field.key" lay-verify="required" placeholder="{:lang('pleaseEnter')}{:lang('seoKeyword')}" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">{:lang('description')}</label>
            <div class="layui-input-block">
                <textarea ng-model="field.des" lay-verify="required" placeholder="{:lang('pleaseEnter')}{:lang('description')}" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">网站LOGO</label>
            <div class="layui-input-block">
                <div class="site-demo-upload">
                    <img id="cltLogo" src="__ADMIN__/images/tong.png">
                    <div class="site-demo-upbar">
                        <input type="file" name="logo" lay-type="images" class="layui-upload-file" id="logo">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('recordNum')}</label>
            <div class="layui-input-3">
                <input type="text" ng-model="field.bah" placeholder="{:lang('pleaseEnter')}{:lang('recordNum')}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">Copyright</label>
            <div class="layui-input-3">
                <input type="text" ng-model="field.copyright" placeholder="{:lang('pleaseEnter')}Copyright" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('companyAddress')}</label>
            <div class="layui-input-3">
                <input type="text" ng-model="field.ads" placeholder="{:lang('pleaseEnter')}{:lang('companyAddress')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('tel')}</label>
            <div class="layui-input-3">
                <input type="text" ng-model="field.tel" placeholder="{:lang('pleaseEnter')}{:lang('tel')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('email')}</label>
            <div class="layui-input-3">
                <input type="text" ng-model="field.email" placeholder="{:lang('pleaseEnter')}{:lang('email')}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="sys">{:lang('submit')}</button>
                <button type="reset" class="layui-btn layui-btn-primary">{:lang('reset')}</button>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/angular.min.js"></script>
{include file="common/mainFoot"/}
<script>
    var m = angular.module('hd',[]);
    m.controller('ctrl',['$scope','$http',function($scope,$http){
        $scope.field = {$system};
        layui.use(['form', 'layer','upload'], function () {
            var form = layui.form(),layer = layui.layer,upload = layui.upload;
            if($scope.field.logo){
                cltLogo.src = "__PUBLIC__"+ $scope.field.logo;
            }
            upload({
                url: '{:url("UpFiles/upload")}',
                title: '上传LOGO',
                ext: 'jpg|png|gif', //那么，就只会支持这三种格式的上传。注意是用|分割。
                success: function(res, input){
                    cltLogo.src = "__PUBLIC__"+res.url;
                    $scope.field.logo = res.url;
                }
            });
            // 登录提交监听
            form.on('submit(sys)', function () {
                // 提交到方法 默认为本身
                $.post("{:url('system/system')}",$scope.field,function(res){
                    if(res.code > 0){
                        layer.msg(res.msg,{time:1800},function(){
                            location.href = res.url;
                        });
                    }else{
                        layer.msg(res.msg,{time:1800});
                    }
                });
            })
        })
    }]);
</script>